package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.text.SimpleDateFormat;
import java.util.HashMap;

/**
 * 旅游攻略
 *
 * @author pengq
 */
@Getter
@Setter
public class Strategy extends BaseDomain {
    /**
     * 普通
     */
    public static final int STATE_COMMON = 0;
    /**
     * 热门
     */
    public static final int STATE_HOT = 1;
    /**
     * 禁用
     */
    public static final int STATE_DISABLE = -1;

    /**
     * 地区
     */
    private Region place;
    /**
     * 标题
     */
    private String title;
    /**
     * 副标题
     */
    private String subTitle;
    /**
     * 封面
     */
    private String coverUrl;
    /**
     * 状态
     */
    private int state;

    /**
     * 点赞数
     */
    private Integer love;

    /**
     * 收藏数
     */
    private Integer collectNum;

    public String getStateName() {
        if (state == STATE_HOT) {
            return "热门";
        } else if (state == STATE_DISABLE) {
            return "禁用";
        } else {
            return "普通";
        }
    }

    public String getJson() {
        HashMap<String, Object> map = new HashMap<>(10);
        map.put("id", id);
        if (place != null) {
            map.put("placeId", place.getId());
            map.put("placeName", place.getName());
        }
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        map.put("collectNum", collectNum);
        return JSON.toJSONString(map);
    }
}